<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>The QuickHashIntHash class</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="quickhashintset.savetostring.html">« QuickHashIntSet::saveToString</a></li>
      <li style="float: right;"><a href="quickhashinthash.add.html">QuickHashIntHash::add »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="book.quickhash.html">Quickhash</a></li>
    <li>The QuickHashIntHash class</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="class.quickhashinthash" class="reference">

 <h1 class="title">The QuickHashIntHash class</h1>
 

 <div class="partintro"><p class="verinfo">(PECL quickhash &gt;= Unknown)</p>


  <div class="section" id="quickhashinthash.intro">
   <h2 class="title">简介</h2>
   <p class="para">
    This class wraps around a hash containing integer numbers, where the
    values are also integer numbers. Hashes are also available as
    implementation of the <span class="interfacename"><a href="class.arrayaccess.html" class="interfacename">ArrayAccess</a></span> interface.
   </p>
   <p class="para">
    Hashes can also be iterated over with <a href="control-structures.foreach.html" class="link"><code class="literal">foreach</code></a> as the <span class="interfacename"><a href="class.iterator.html" class="interfacename">Iterator</a></span> interface is
    implemented as well. The order of which elements are returned in is not
    guaranteed.
   </p>
  </div>


  <div class="section" id="quickhashinthash.synopsis">
   <h2 class="title">类摘要</h2>


   <div class="classsynopsis">
    <div class="ooclass"></div>


    <div class="classsynopsisinfo">
     <span class="ooclass">
      <span class="modifier">class</span> <strong class="classname">QuickHashIntHash</strong>
     </span>
     {</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 常量 */</div>
    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">int</span>
      <var class="fieldsynopsis_varname"><a href="class.quickhashinthash.html#quickhashinthash.constants.check-for-dupes"><var class="varname">CHECK_FOR_DUPES</var></a></var><span class="initializer"> = 1</span>;</div>

    <div class="fieldsynopsis"><span class="modifier">const</span>
     <span class="type">int</span>
      <var class="fieldsynopsis_varname"><a href="class.quickhashinthash.html#quickhashinthash.constants.do-not-use-zend-alloc"><var class="varname">DO_NOT_USE_ZEND_ALLOC</var></a></var><span class="initializer"> = 2</span>;</div>

    <div class="fieldsynopsis"><span class="modifier">const</span>
     <span class="type">int</span>
      <var class="fieldsynopsis_varname"><a href="class.quickhashinthash.html#quickhashinthash.constants.hasher-no-hash"><var class="varname">HASHER_NO_HASH</var></a></var><span class="initializer"> = 256</span>;</div>

    <div class="fieldsynopsis"><span class="modifier">const</span>
     <span class="type">int</span>
      <var class="fieldsynopsis_varname"><a href="class.quickhashinthash.html#quickhashinthash.constants.hasher-jenkins1"><var class="varname">HASHER_JENKINS1</var></a></var><span class="initializer"> = 512</span>;</div>

    <div class="fieldsynopsis"><span class="modifier">const</span>
     <span class="type">int</span>
      <var class="fieldsynopsis_varname"><a href="class.quickhashinthash.html#quickhashinthash.constants.hasher-jenkins2"><var class="varname">HASHER_JENKINS2</var></a></var><span class="initializer"> = 1024</span>;</div>


    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 方法 */</div>
    <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><a href="quickhashinthash.add.html" class="methodname">add</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$key</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$value</code><span class="initializer"> = ?</span></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="quickhashinthash.construct.html" class="methodname">__construct</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$size</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$options</code><span class="initializer"> = ?</span></span>)</div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="quickhashinthash.delete.html" class="methodname">delete</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$key</code></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="quickhashinthash.exists.html" class="methodname">exists</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$key</code></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="quickhashinthash.get.html" class="methodname">get</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$key</code></span>): <span class="type">int</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="quickhashinthash.getsize.html" class="methodname">getSize</a></span>(): <span class="type">int</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="modifier">static</span> <span class="methodname"><a href="quickhashinthash.loadfromfile.html" class="methodname">loadFromFile</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$filename</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$options</code><span class="initializer"> = ?</span></span>): <span class="type"><a href="class.quickhashinthash.html" class="type QuickHashIntHash">QuickHashIntHash</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="modifier">static</span> <span class="methodname"><a href="quickhashinthash.loadfromstring.html" class="methodname">loadFromString</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$contents</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$options</code><span class="initializer"> = ?</span></span>): <span class="type"><a href="class.quickhashinthash.html" class="type QuickHashIntHash">QuickHashIntHash</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="quickhashinthash.savetofile.html" class="methodname">saveToFile</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$filename</code></span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="quickhashinthash.savetostring.html" class="methodname">saveToString</a></span>(): <span class="type">string</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="quickhashinthash.set.html" class="methodname">set</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$key</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$value</code></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="quickhashinthash.update.html" class="methodname">update</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$key</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$value</code></span>): <span class="type">bool</span></div>

   }</div>


  </div>


  <div class="section" id="quickhashinthash.constants">
   <h2 class="title">预定义常量</h2>
   <dl>

    
     <dt id="quickhashinthash.constants.check-for-dupes"><strong><code>QuickHashIntHash::CHECK_FOR_DUPES</code></strong></dt>

     <dd>

      <p class="para">If enabled, adding duplicate elements to a set (through either <span class="methodname"><a href="quickhashinthash.add.html" class="methodname">QuickHashIntHash::add()</a></span> or
      <span class="methodname"><a href="quickhashinthash.loadfromfile.html" class="methodname">QuickHashIntHash::loadFromFile()</a></span>) will result in those elements to be dropped from the
      set. This will take up extra time, so only used when it is required.</p>
     </dd>

    

    
     <dt id="quickhashinthash.constants.do-not-use-zend-alloc"><strong><code>QuickHashIntHash::DO_NOT_USE_ZEND_ALLOC</code></strong></dt>

     <dd>

      <p class="para">Disables the use of PHP&#039;s internal memory manager for internal
      set structures. With this option enabled, internal allocations will not
      count towards the <a href="ini.core.html#ini.memory-limit" class="link">memory_limit</a> settings.</p>
     </dd>

    

    
     <dt id="quickhashinthash.constants.hasher-no-hash"><strong><code>QuickHashIntHash::HASHER_NO_HASH</code></strong></dt>

     <dd>

      <p class="para">Selects to not use a hashing function, but merely use a modulo to
      find the bucket list index. This is not faster than normal hashing, and
      gives more collisions.</p>
     </dd>

    

    
     <dt id="quickhashinthash.constants.hasher-jenkins1"><strong><code>QuickHashIntHash::HASHER_JENKINS1</code></strong></dt>

     <dd>

      <p class="para">This is the default hashing function to turn the integer hashes
      into bucket list indexes.</p>
     </dd>

    

    
     <dt id="quickhashinthash.constants.hasher-jenkins2"><strong><code>QuickHashIntHash::HASHER_JENKINS2</code></strong></dt>

     <dd>

      <p class="para">Selects a variant hashing algorithm.</p>
     </dd>

    

   </dl>

  </div>



 </div>

 





















































































<h2>目录</h2><ul class="chunklist chunklist_reference"><li><a href="quickhashinthash.add.html">QuickHashIntHash::add</a> — This method adds a new entry to the hash</li><li><a href="quickhashinthash.construct.html">QuickHashIntHash::__construct</a> — Creates a new QuickHashIntHash object</li><li><a href="quickhashinthash.delete.html">QuickHashIntHash::delete</a> — This method deletes an entry from the hash</li><li><a href="quickhashinthash.exists.html">QuickHashIntHash::exists</a> — This method checks whether a key is part of the hash</li><li><a href="quickhashinthash.get.html">QuickHashIntHash::get</a> — This method retrieves a value from the hash by its key</li><li><a href="quickhashinthash.getsize.html">QuickHashIntHash::getSize</a> — Returns the number of elements in the hash</li><li><a href="quickhashinthash.loadfromfile.html">QuickHashIntHash::loadFromFile</a> — This factory method creates a hash from a file</li><li><a href="quickhashinthash.loadfromstring.html">QuickHashIntHash::loadFromString</a> — This factory method creates a hash from a string</li><li><a href="quickhashinthash.savetofile.html">QuickHashIntHash::saveToFile</a> — This method stores an in-memory hash to disk</li><li><a href="quickhashinthash.savetostring.html">QuickHashIntHash::saveToString</a> — This method returns a serialized version of the hash</li><li><a href="quickhashinthash.set.html">QuickHashIntHash::set</a> — This method updates an entry in the hash with a new value, or
  adds a new one if the entry doesn't exist</li><li><a href="quickhashinthash.update.html">QuickHashIntHash::update</a> — This method updates an entry in the hash with a new value</li></ul>
</div>
</div></div></body></html>